public class LC1588E {
    public int sumOddLengthSubarrays(int[] arr) {
        int sum=0;
        int n=arr.length;
        if (n==0)
            return 0;
        for (int i = 0; i < n; i++) {
            int index=i;
            int subsum=arr[i];
            sum+=subsum;
            while (index+2<n){
                index+=2;
                subsum+=arr[index]+arr[index-1];
                sum+=subsum;
            }
        }
        return sum;
    }
}
